package gui;

import gui.control.ControlRecomendation;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JList;
import javax.swing.JLabel;
import java.awt.Font;
import java.io.IOException;

public class AutocompleteWindow extends JFrame {

	private JPanel contentPane;
	private String [] dataList;
	private ControlRecomendation control;

	/**
	 * Create the frame.
	 * @param urlIndexProd Is the URL where the Products Index is Located. The URL has to be complete from start to end.
	 */
	public AutocompleteWindow(String urlIndexProd) {
		setTitle("Search Helper");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 266);
		contentPane = new JPanel();
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		JList list = new JList();
		list.setBounds(10, 42, 302, 172);
		contentPane.add(list);
		
		JLabel lblResults = new JLabel("Results");
		lblResults.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblResults.setBounds(10, 11, 92, 20);
		contentPane.add(lblResults);
		
		//Index Initialization
		try {
			this.control.openIndex(urlIndexProd);
		} catch (IOException e) {
			System.err.println("Problem opening the --Products Index--");
			e.printStackTrace();
		}
	}

	public String[] getDataList() {
		return dataList;
	}

	public void setDataList(String[] dataList) {
		this.dataList = dataList;
		this.contentPane.repaint();
	}
	
}
